class Solution:
    def permute(self, nums: List[int]) -> List[List[int]]:
        e=[]
        n = len(nums)
        def func(a, m):
            if len(a)==1:
                e.append(m+a)
            else:
                for i in range(len(a)):
                    c = a[:]
                    d = c.pop(i)
                    m.append(d)
                    func(c, m)
                    m.pop()
    
        func(nums, [])
        return e